package com.huanletao.tran.demo;

import java.sql.*;

public class Demo05 {
    public static void main(String[] args) throws SQLException, ClassNotFoundException, InterruptedException {

        Connection[] connections = new Connection[10];
        for (int i=0;i<9;i++){
            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            classLoader.loadClass("com.mysql.jdbc.Driver");
//        2.用户信息和url
            String url = "jdbc:mysql:///push_platform?useSSL=false";
            String username="root";
            String password="root";
//        3.连接成功，数据库对象 Connection
            Connection connection = DriverManager.getConnection(url,username,password);
            connections[i] = connection;
        }
        Thread.sleep(2000);

        for (int i = 0; i<9;i++){
            Connection connection = connections[i];
            PreparedStatement prepareStatement = connection.prepareStatement("select * from sys_user");
            ResultSet resultSet = prepareStatement.executeQuery();
            while(resultSet.next()){
                System.out.println("SNo="+resultSet.getString("user_id"));
                System.out.println("SName="+resultSet.getString("login_name"));
                System.out.println("Birth="+resultSet.getString("user_name"));
                System.out.println("SPNo="+resultSet.getString("phonenumber"));
            }

            System.out.println("=============================");

        }

        for (;;){}

    }
}
